package com.songcha.library_common.ui.view

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.widget.SeekBar

/***
 * fix system seekbar bug of setProgressDrawable will deformation
 */
@SuppressLint("AppCompatCustomView")
class CustomSeekBar
@JvmOverloads
constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyle: Int = 0,
    defRes: Int = 0
) : SeekBar(context,attrs,defStyle,defRes) {

    override fun setProgressDrawable(d: Drawable?) {
        if(d==null) return

        if(progressDrawable!=null){
            val bounds=progressDrawable.bounds
            super.setProgressDrawable(d)
            progressDrawable.bounds=bounds
        }else{
            super.setProgressDrawable(d)
        }

    }

}